import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class StyleDemo extends StatelessWidget {
  const StyleDemo({super.key});

  @override
  Widget build(BuildContext context) {
    // Widget dialogBox = Container();
    // String textCtx = '';
    // bool isIOS = Platform.isIOS;
    // bool isAndroid = Platform.isAndroid;
    // if (isIOS) {
    //   dialogBox = const CupertinoDemo();
    //   textCtx = 'Cupertino - IOS风格';
    // }
    // else if (isAndroid) {
    //   dialogBox = const MaterialDemo();
    //   textCtx = 'Cupertino - 安卓风格';
    // }
    // return Container(
    //   child: Column(
    //     children: [
    //       Text(textCtx),
    //       dialogBox
    //     ],
    //   ),
    // );

    return Container(
      child: const Column(
        children: [
          Text('Cupertino - 安卓风格'),
          MaterialDemo(),
          Text('Cupertino - IOS风格'),
          CupertinoDemo()
        ],
      ),
    );
  }

}


class MaterialDemo extends StatelessWidget {
  const MaterialDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: AlertDialog(
        title: Text('提示'),
        content: Text('确认删除吗？'),
        actions: [
          TextButton(
            onPressed: (){
              print('取消的逻辑');
            },
            child: Text('取消')
          ),
          TextButton(
              onPressed: (){
                print('确认的逻辑');
              },
              child: Text('确认')
          ),
        ],
      ),
    );
  }
  
}

class CupertinoDemo extends StatelessWidget {
  const CupertinoDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: CupertinoAlertDialog(
        title: Text('提示'),
        content: Text('确认删除吗？'),
        actions: [
          CupertinoDialogAction(
              onPressed: (){
                print('取消的逻辑');
              },
              child: Text('取消')
          ),
          CupertinoDialogAction(
              onPressed: (){
                print('确认的逻辑');
              },
              child: Text('确认')
          ),
        ],
      ),
    );
  }

}